<!-- eslint-disable vue/html-indent -->
<template>
  <view class="mgt1" v-if="props.setList.length > 0">
    <tm-sheet
      :margin="[0]"
      :padding="[32, 20]"
      v-for="(item, index) in props.setList"
      :key="index"
    >
      <directory-main
        :key="item.id"
        :content="item"
        :index="index"
        :isShowRight="!isSearchFlag ? true : false"
        :isSelectMode="false"
        :enableTouch="false"
        @btnClick="goData"
      ></directory-main>
    </tm-sheet>
  </view>

  <tm-sheet v-else :margin="[0]">
    <tm-result :showBtn="false" subTitle=" " title="暂无数据"></tm-result>
  </tm-sheet>
</template>

<script lang="ts" setup>
import { IFile } from '@/ts/core'
import { watch, ref } from 'vue'
import directoryMain from '@/components/Directory/main.vue'

type Props = {
  setList: IFile[]
  searchFlag: boolean
}
const props = defineProps<Props>()
const isSearchFlag = ref(false)
const emit = defineEmits(['btnClick'])
watch(
  () => props.searchFlag,
  newVal => {
    isSearchFlag.value = newVal // 根据外部传入的值来设置选择模式
  }
)
const goData = (item: IFile, _index: number, type: string) => {
  //更新点击数据
  emit('btnClick', item, type)
}
</script>

<style lang="scss">
@import '../../common/style/global.scss';
</style>
